import { createPinia } from 'pinia'
import { createApp } from 'vue'

import '@/assets/const.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import App from './App.vue'
import Login from './Login.vue'
import router from './router'
import { http, method } from './utils/http'

http.request("/login", {
        method: method.POST, 
    }, (data: any)=>{
        if(data.status == "success"){
            AppPage()
        }else{
            loginPage()
        }
    }, 
    (er: any)=>{
        loginPage()
    }
)

/** 登录页 */
function loginPage(){
    const app =  createApp(Login) ;
    app.use(createPinia())
    app.use(ElementPlus, {locale: zhCn,})
    app.mount('#app')
}

/** 应用页 */
function AppPage(){
    const app =  createApp(App) ;
    app.use(router);
    app.use(createPinia())
    app.use(ElementPlus, {locale: zhCn,})
    app.mount('#app')
}